let lasttime = document.getElementById("time");
let text = document.getElementById("text");
var time = 5;
function color() {
  let r = Math.floor(Math.random() * 255);
  let g = Math.floor(Math.random() * 255);
  let b = Math.floor(Math.random() * 255);
  return "rgb(" + r + "," + g + "," + b + "" + ")";
}
function count() {
  PureColor();
  time--;
  lasttime.innerHTML = time;
  document.body.style.background = ChangeColor();
  text.style.color = ChangeColor();
  if (time == 0) {
    clearInterval(ti);
    text.innerHTML = "马上跳转咯";
    text.style.color = "red";
    toWust();
  }
  if (0) {
    text.innerHTML = "骗你的，还没跳转呢";
    text.style.color = "red";
  }
  if (0) {
    clearInterval(ti);
    text.innerHTML = "这次真要跳转了";
    text.style.color = "red";
    toWust();
  }
}
let ti = setInterval(count, 1000);

function toWust() {
  window.location = "https://www.wust.edu.cn";
}
function ChangeColor() {
  text.style.color = color();
  document.body.style.background = color();
}
function PureColor() {
  let num = Math.random() * 100;
  if (num > 50) {
    text.style.color = "rgb(0, 0, 0)";
    document.body.style.background = "rgb(255, 255, 255)";
  } else {
    text.style.color = "rgb(255, 255, 255)";
    document.body.style.background = "rgb(0, 0, 0)";
  }
}
